package cn.tedu._01mvcboot01.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class BMIController {
    @RequestMapping("/bim")
    @ResponseBody
    public String bim(double height ,double weight){
        short bmi = (short) (weight / (height * height));
        if (bmi < 18.5) return "过轻";
        if (bmi < 23) return "正常";     // 亚洲标准下限
        if (bmi < 27.5) return "过重";  // 亚洲标准
        return "肥胖";
        
    }
    @GetMapping("v1/bmi/{height}/{weight}")
    @ResponseBody
    public String bmi2(@PathVariable Double height, @PathVariable Double weight){
        short bmi = (short) (weight / (height * height));
        if (bmi < 18.5) return "过轻";
        if (bmi < 23) return "正常";     // 亚洲标准下限
        if (bmi < 27.5) return "过重";  // 亚洲标准
        return "肥胖";
    }

}
